<nav aria-label="Page navigation">
  <ul class="pagination">
{#  page_obj.has_previous 布尔值是否有前一页#}
      {% if page_obj.has_previous %}
{#          如果当前页面有前一页#}
          <li><a href="?page={{ page_obj.previous_page_number }}">&laquo;</a></li>
      {% else %}
{#          如果当前页面没有前一页禁用前一页按钮#}
          <li class="disabled"><a>&laquo;</a></li>
      {% endif %}
{#     paginator.page_range 页面范围#}

    {% for page_number in paginator.page_range %}
{#        page_obj.number 当前页面是第几页#}
        {% if page_number != page_obj.number %}
{#            生成页码并且添加链接#}
            <li><a href="?page={{ page_number }}">{{ page_number }}</a></li>
        {% else %}
            <li class="active"><a>{{ page_number }}</a></li>
        {% endif %}
    {% endfor %}

    {% if page_obj.has_next %}
{#        如果有下一页 链接到下一页页码#}
        <li><a href="?page={{ page_obj.next_page_number }}">&rsaquo;</a></li>
    {% else %}
{#        否则禁用下一页按钮#}
        <li class="disabled"><a>&rsaquo;</a></li>
    {% endif %}
  </ul>
</nav>